package com.twu.biblioteca;

import java.io.PrintStream;
import java.util.List;

/**
 * Created by thoughtworker on 1/21/14.
 */
public class Library {

    private List<Book> bookList;
    private PrintStream printStream;

    public Library(List<Book> bookList, PrintStream printStream){
        this.bookList = bookList;
        this.printStream = printStream;
    }

    public void listAvailableBooks() {
        if (bookList.isEmpty())
            printStream.println("No books");
        else{
            for (Book book : bookList){
                printStream.println(book.toString());
            }
        }
    }

    public Book findItem(String title) {
        for (Book book : bookList){
            if(book.getTitle().equals(title))
                return book;
        }
        return null;
    }
}
